﻿namespace Tentacle.Downloader
{
    using System;
    using System.Net;
    using System.Threading.Tasks;

    interface IConnectionService:IDisposable
    {
        /// <summary>
        /// 获取当前的GUID
        /// </summary>
        string Guid { get; }

        /// <summary>
        /// 
        /// </summary>
        bool Connected { get; }

        /// <summary>
        /// 
        /// </summary>
        IPEndPoint LocalEndPoint { get; }

    }

    interface IServerService : IConnectionService
    {
        /// <summary>
        /// 
        /// </summary>
        void Start();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="token"></param>
        event Action<string> SetToken;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="site"></param>
        event Func<string,Task<string>> SetSite;

        /// <summary>
        /// 
        /// </summary>
        event Action Disconnect;


    }

    interface IClientService : IConnectionService
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="iP"></param>
        void Connect(IPEndPoint iP);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="content"></param>
        void SetToken(string token);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="site"></param>
        void SetSite(string site);

        /// <summary>
        /// 
        /// </summary>
        void Disconnet();

        /// <summary>
        /// 
        /// </summary>
        event Action<string> DownloadedCompleted;

        /// <summary>
        /// 
        /// </summary>
        event Action<string> DownloadedErrorRaised;

        /// <summary>
        /// 
        /// </summary>
        event Action Disconnected;
    }
}
